
public class DuckSimulator {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		DuckSimulator simulator = new DuckSimulator();
		
		AbstractDuckFactory duckFactory = new CountingDuckFactory();
		simulator.simulate(duckFactory);

	}
	
	void simulate(IQuackable duck)
	{
		duck.quack();
	}
	
	void simulate(AbstractDuckFactory duckFactory)
	{		
		IQuackable redheadDuck = duckFactory.createRedheadDuck();
		IQuackable DuckCall = duckFactory.createDuckCall();
		IQuackable rubberDuck = duckFactory.createRubberDuck();
		IQuackable gooseDuck = new GooseAdapter(new Goose());
		
		System.out.println("\nDuck Simulator : With Coimposite - Flocks");
		
		Flock flockOfDucks = new Flock();
				
		flockOfDucks.add(redheadDuck);
		flockOfDucks.add(DuckCall);
		flockOfDucks.add(rubberDuck);
		flockOfDucks.add(gooseDuck);
		
		Flock flockOfMallards = new Flock();
		
		for (int i = 0 ; i < 4 ; i ++)
		{
			IQuackable mallard = duckFactory.createMallardDuck();
			flockOfMallards.add(mallard);
		}
		flockOfDucks.add(flockOfMallards);
			
		System.out.println("\nDuck Simulator : Whole Flock Simulation");
		simulate(flockOfDucks);
		
		System.out.println("\nDuck Simulator : Mallard Flock Simulation");
		simulate(flockOfMallards);
		
		System.out.println("The ducks quacked " + QuackCounter.getQuacks() + "times");
	}
}
